
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Compression;
using System.IO;

namespace Swaf.Compression
{
    public class CompressionClassFactory
    {
        /// <summary>
        /// Factory to create a GZipStream
        /// </summary>
        /// <param name="stream">The stream that will be compressed or decompressed</param>
        /// <param name="forCompression">Indicates whether Compression or Decompress will occur</param>
        /// <param name="keepInnerStreamOpen">Denote whether to keep the compressed/decompressed stream open or not</param>
        /// <returns>Instance of the GZipStream</returns>
        public static Stream GetGZipStream(Stream stream, Boolean forCompression, Boolean keepInnerStreamOpen)
        {
            return new GZipStream(stream, forCompression ? CompressionMode.Compress : CompressionMode.Decompress, keepInnerStreamOpen);
        }

        /// <summary>
        /// Factory to create a DeflateStream
        /// </summary>
        /// <param name="stream">The stream that will be compressed or decompressed</param>
        /// <param name="forCompression">Indicates whether Compression or Decompress will occur</param>
        /// <param name="keepInnerStreamOpen">Denote whether to keep the compressed/decompressed stream open or not</param>
        /// <returns>Instance of the DeflateStream</returns>
        public static Stream GetDeflateStream(Stream stream, Boolean forCompression, Boolean keepInnerStreamOpen)
        {
            return new DeflateStream(stream, forCompression ? CompressionMode.Compress : CompressionMode.Decompress, keepInnerStreamOpen);
        }
    }
}
